<template>
	<view class="container">
		<u-navbar :isBack="true" title="申请入驻" title-color="#fff" back-icon-color="#fff"
		:background="{background: '#FF9762'}" :borderBottom="false"></u-navbar>
		<!-- 地图部分 (占40%) -->
		<view class="map-container" style="background: #FF9762;">
			<view style="margin-top: 3vh;padding: 0 80px;">
				<!-- <u-steps :list="numList" :current="0" un-active-color="#fff" mode="number"
				icon="minus"></u-steps> -->
				<view style="display: flex;align-items: center;">
					<view style="padding-left: 18px;">
						<view style="width: 40rpx;height: 40rpx;background: #fff;border-radius: 50%;
						display: flex;align-items: center;justify-content: center;">
							<view style="background: #FF9762;border-radius: 50%;width: 20rpx;height: 20rpx;"></view>
						</view>
					</view>
					<view style="height: 1px;background: #fff;flex: 1;"></view>
					<view style="padding-right: 18px;">
						<view style="width: 40rpx;height: 40rpx;background: #fff;border-radius: 50%;
						display: flex;align-items: center;justify-content: center;">
							<view style="background: #FF9762;border-radius: 50%;width: 20rpx;height: 20rpx;"></view>
						</view>
					</view>
				</view>
				<view style="display: flex;align-items: center;color: #fff;margin-top: 20rpx;">
					<view style="">商家认证</view>
					<view style="flex: 1;"></view>
					<view style="">店铺资料</view>
				</view>
			</view>
		</view>
		
		<!-- 其他内容部分 (占60%) -->
		<view class="content-container">
			<view style="font-weight: bold;">商户名称</view>
			<view class="location-info" style="">
				<!-- <text class="location-text">当前位置: {{address || '正在获取...'}}</text> -->
				<input type="text" placeholder="请输入营业执照上的商户名称" v-model="formData.business_name" />
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;">
				<view style="font-weight: bold;">商户类型</view>
				<view style="margin-top: 20rpx;">
					<!-- @change="radioGroupChange" -->
					<u-radio-group v-model="formData.business_type" >
						<u-radio :name="1">企业</u-radio>
						<u-radio :name="2">个体工商户</u-radio>
					</u-radio-group>
				</view>
			</view>
			<view style="font-weight: bold;margin-top: 20rpx;">社会统一信用代码</view>
			<view class="location-info">
				<input type="text" placeholder="请输入社会统一信用代码" v-model="formData.business_code" />
			</view>
			
			<view style="font-weight: bold;margin-top: 20rpx;">营业执照</view>
			<view class="location-info" style="padding: 40px;" @click="uploadImg('business_image')">
				<image :src="formData.business_image" mode="widthFix" style="width: 100%;" v-if="formData.business_image"></image>
				<image src="@/static/icon/yyzz.png" mode="widthFix" style="width: 100%;" v-else></image>
			</view>
			
			<view style="font-weight: bold;margin-top: 20rpx;">法人姓名</view>
			<view class="location-info" style="">
				<input type="text" placeholder="请输入法人姓名" v-model="formData.legal_name" />
			</view>
			<view style="font-weight: bold;margin-top: 20rpx;">法人手机号</view>
			<view class="location-info" style="">
				<input type="text" placeholder="请输入法人手机号" v-model="formData.legal_mobile" />
			</view>
			<view style="font-weight: bold;margin-top: 20rpx;">法人身份证号</view>
			<view class="location-info" style="">
				<input type="text" placeholder="请输入法人身份证号" v-model="formData.legal_code" />
			</view>
			
			<view style="font-weight: bold;">身份证照片(人像面)</view>
			<view class="location-info" style="padding: 40px;" @click="uploadImg('legal_zm_image')">
				<image :src="formData.legal_zm_image" mode="widthFix" style="width: 100%;" v-if="formData.legal_zm_image"></image>
				<image src="/static/my/sfz.png" mode="widthFix" style="width: 100%;" v-else></image>
			</view>
			<view style="font-weight: bold;">身份证照片(国徽面)</view>
			<view class="location-info" style="padding: 40px;" @click="uploadImg('legal_fm_image')">
				<image :src="formData.legal_fm_image" mode="widthFix" style="width: 100%;" v-if="formData.legal_fm_image"></image>
				<image src="/static/my/sfz.png" mode="widthFix" style="width: 100%;" v-else></image>
			</view>
		</view>
		
		<view style="background: #FF9762;height: 160rpx;padding: 34rpx;">
			<view style="padding: 10px;text-align: center;background-color: #fff;
			border-radius: 5px;" @click="goXia">下一步</view>
		</view>
	</view>
</template>

<script>
import configApi from 'utils/config.js';
import { request } from 'utils/request.js';
export default {
	data() {
		return {
			value: 1,
			
			numList: [
				{ name: '商家认证' }, 
				{ name: '店铺资料' },
			],
			
			formData: {
				business_name: '',
				business_type: 1,
				business_code: '',
				business_image: '',
				
				legal_name: '',
				legal_mobile: '',
				legal_code: '',
				legal_zm_image: '',
				legal_fm_image: '',
			}
		}
	},
	onLoad() {},
	methods: {
		uploadImg(e){
			let that = this;
			let vulurl = e;
			uni.chooseImage({
				count: 1,
				success: (res) => {
					request.uploadFileImg({
						url: '/common/upload',
						data: res.tempFilePaths[0],
					}).then(res => {
						console.log('data-', res);
						that.formData[vulurl] = res;
					});
					// let tempFilePath = res.tempFilePaths;
					// console.log(tempFilePath);
					// if (tempFilePath.length > 0) {
					// 	for(let i = 0; i<tempFilePath.length; i++){
					// 		request.uploadFileImg({
					// 			url: '/common/upload',
					// 			data: tempFilePath[i],
					// 		}).then(res => {
					// 			console.log('data-', res);
					// 			// that.shopForm.logo = res;
					// 		});
					// 	}
					// }
				}
			});
		},
		// 下一步
		goXia(){
			uni.setStorageSync('applypFormData', this.formData);
			uni.navigateTo({
				url: '/pages/merchant/applyinfo',
			});
		},
	}
}
</script>

<style>
	.container {
		display: flex;
		flex-direction: column;
		height: 100vh;
		width: 100%;
	}

	.map-container {
		height: 11vh; /* 占40%高度 */
		width: 100%;
	}

	.map {
		width: 100%;
		height: 100%;
	}

	.content-container {
		flex: 1; /* 剩余60%高度 */
		padding: 15px;
		overflow-y: auto;
	}

	.location-info {
		padding: 15px;
		background-color: #f5f5f5;
		border-radius: 5px;
		margin-bottom: 15px;
		margin-top: 20rpx;
	}

	.location-text {
		font-size: 14px;
		color: #333;
	}

	.other-content {
		padding: 10px;
	}
</style>